{php include wl_template('common/header');}
<ul class="nav nav-tabs" id="myTab">
	<li class="active"><a href="#">添加卡券</a></li>
</ul>
<div class="app-content">
	<div class="app-form">
		<form action="" method="post" class="form-horizontal form form-validate" id="commentForm">
			<div class="tab-content">
				<div class="tab-pane  active" id="tab_rush">
					<div class="panel panel-default">
						<div class="panel-heading">卡券信息</div>
						<div class="panel-body">
							<div class="form-group"  style="display: block;">
								<label class="col-sm-2 control-label">卡券标题</label>
								<div class="col-sm-9">
									<input type="text" name="coupon[title]" class="form-control" value="{$coupon['title']}" placeholder="填写活动名称，默认与商户名称相同" id="storetitle" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">是否收费</label>
								<div class="col-sm-9">
									<label class="radio-inline" onclick="$('#couprice').hide();" >
										<input type="radio" value="0" name="coupon[is_charge]" {if $coupon['is_charge'] == 0 || empty($coupon) } checked {/if}>免费
									</label>
									<label class="radio-inline" onclick="$('#couprice').show();" >
										<input type="radio" value="1" name="coupon[is_charge]" {if $coupon['is_charge'] == 1 } checked {/if}>收费
									</label>
								</div>
							</div>
							<div class="form-group" id="couprice" {if $coupon['is_charge'] == 0 || empty($coupon) } style="display: none;" {else}  style="display: block;" {/if} >
								<label class="col-sm-2 control-label">卡券价格</label>
								<div class="col-sm-9">
									<input type="text" name="coupon[price]" class="form-control" value="{$coupon['price']}" placeholder="用于展示卡券价值，请填入正整数" id="price" />
								</div>
							</div>
							<div class="form-group"  style="display: block;">
								<label class="col-sm-2 control-label">外链地址</label>
								<div class="col-sm-9">
									<input type="text" name="coupon[extlink]" class="form-control" value="{$coupon['extlink']}" placeholder="卡券要跳转的外部链接" id="extlink" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">卡券logo</label>
								<div class="col-sm-9">
									{php echo attachment_select('coupon[logo]', $coupon['logo']);}
								</div>
							</div>
							<div class="form-group"  style="display: block;">
								<label class="col-sm-2 control-label">卡券提供方名称</label>
								<div class="col-sm-9">
									<input type="text" name="extinfo[storename]" class="form-control" value="{$coupon['storename']}" placeholder="卡券提供方名称"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">简要说明</label>
								<div class="col-sm-9">
									<input type="text" name="coupon[sub_title]" class="form-control" value="{$coupon['sub_title']}"  id="use_limit" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">适用等级</label>
								<div class="col-sm-9">
									<div class="form-control-block">
										<label class="checkbox-inline">
											<input type="checkbox" value="0" {if in_array(0,$coupon['level'])} checked {/if}  name="coupon[level][]" />{$_W['wlsetting']['halflevel']['name']}
										</label>
										{loop $levels $level}
										<label class="checkbox-inline">
											<input type="checkbox" value="{$level['id']}" {if in_array($level['id'],$coupon['level'])} checked {/if}  name="coupon[level][]" />{$level['name']}
										</label>
										{/loop}
									</div>
									<span class="help-block">如果全都不勾选则默认全等级可用</span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">活动时间</label>
								<div class="col-sm-9">
									<div class="input-group">
										{php echo tpl_select_time_info('datetime',array('starttime'=>date('Y-m-d H:i:s',$datestarttime),'endtime'=>date('Y-m-d H:i:s',$dateendtime)));}
									</div>
								</div>
							</div>
							<div class="form-group"  style="display: block;">
								<label class="col-sm-2 control-label">卡券排序</label>
								<div class="col-sm-9">
									<input type="tel" class="form-control" name="coupon[indexorder]" value="{$coupon[indexorder]}"/>
									<span class="help-block">请输入整数数字，序号越大，排序靠前</span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">使用说明</label>
								<div class="col-sm-9">
									{php echo tpl_diy_editor_create('coupon[description]', $coupon['description']);}
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">列表显示</label>
								<div class="col-sm-9">
									<label class="radio-inline">
		                                <input type="radio" value="0" name="coupon[is_indexshow]" {if $coupon['is_indexshow'] == 0 || empty($coupon) } checked {/if}>启用
		                            </label>
									<label class="radio-inline">
		                                <input type="radio" value="1" name="coupon[is_indexshow]" {if $coupon['is_indexshow'] == 1 } checked {/if}>禁用
		                            </label>
									<div class="help-block">关闭后，在首页和一卡通列表页面不会显示该卡券</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">状态</label>
								<div class="col-sm-9">
									<input type="checkbox" class="js-switch" name="coupon[status]" {if $coupon['status'] == 2 || empty($coupon) } checked="checked" {/if}>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-9">
					<input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</div>
		</form>
	</div>
</div>
<script>
$(function () {
	window.optionchanged = false;
	$('#myTab a').click(function (e) {
		e.preventDefault();//阻止a链接的跳转行为
		$(this).tab('show');//显示当前选中的链接及关联的content
	});
});
</script>
<script language='javascript'>
	$('#commentForm').submit(function(){
		if($('#storetitle').val() == '') {
	    	util.tips("请填写卡券名称");
	    	$('#storetitle').focus();
			return false;
		}
		if($('#extlink').val() == '') {
	    	util.tips("请填写外部链接地址");
	    	$('#extlink').focus();
			return false;
		}
		return true;
	});



</script>
{php include wl_template('common/footer');}